home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 July / Macworld (1999-07).dmg / Serious Software / OpenWorld demo 2.0 / Development / DoubleTag / Upcase / UPCASE.c next >
Text File  |  1999-04-21  |  1KB  |  56 lines

  1. /*  File: Upcase.c      
  2.     Copyright (c) 1999 Marco Bambini. All rights reserved.
  3.  
  4.     Description: transform to uppercase the text between the <UPCASE> </UPCASE> tags
  5. */
  6.  
  7. #include "OpenWorld_plugIn.h"
  8. #include <CodeFragments.h>
  9.  
  10. Boolean main (dataPtr param)
  11. {    
  12.     switch (param->message)
  13.     {
  14.         case init_message:
  15.             {
  16.                 param->version=kVersion;
  17.                 param->customData=kUnused;
  18.             }
  19.             break;
  20.             
  21.         case run_message:
  22.             {
  23.                 long    l=0,i=0;
  24.                 
  25.                 if (param->dim==0) return NULL;
  26.                 if (param->inputText==NULL) return NULL;
  27.                 
  28.                 // the lenght of the text
  29.                 l=param->dim;
  30.                 
  31.                 // allocate space for the return buffer
  32.                 param->outputText=(char *)OW_NewPtr(param,l);
  33.                 if (param->outputText==NULL) {param->dim=0;return NULL;}
  34.  
  35.                 // perform the operation
  36.                 while (param->inputText[i])
  37.                     {param->outputText[i]=(char)toupper(param->inputText[i]);i++;}
  38.             }
  39.             break;
  40.         
  41.         case stop_message:
  42.             {
  43.                 // dispose the buffer
  44.                 OW_DisposePtr(param,param->outputText);
  45.             }
  46.             break;
  47.             
  48.         case end_message:
  49.             {    
  50.                 // do nothing
  51.             }
  52.             break;
  53.     }
  54.     // Ask OpenWorld to send the text between <UPCASE> and </UPCASE> in the run_message
  55.     return kDoubleTag;
  56. }